Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto: Remove inner mutable shared state from Account #2710

Merged
merged 19 commits into from
Oct 20, 2023

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Oct 12, 2023

The Account is lazily loaded in the cache, and transferred from the cache to PendingChanges in case of StoreTransaction. Later, Account is made not cloneable anymore, and inner mutable shared state is removed from there, so we can identify which interactions with the cache must be transactions (i.e. which Account function calls require write access), and which can just be reads from the cache (i.e. which Account function calls requires read-only access). Eventually, the cache is put behind a RwLock, so we can't read and write to the cache at the same time; this lock is taken in write access during transactions, and in read-only access during cache reads.

This can be reviewed commit by commit.

Multiple parts of #2624.

@bnjbvr bnjbvr requested a review from poljar October 12, 2023 14:32
@bnjbvr bnjbvr requested a review from a team as a code owner October 12, 2023 14:32
@bnjbvr bnjbvr force-pushed the storetransaction-optional-account branch from caacc24 to 04396eb Compare October 12, 2023 14:52
@bnjbvr bnjbvr marked this pull request as draft October 13, 2023 08:51
@bnjbvr bnjbvr marked this pull request as ready for review October 13, 2023 14:48
@bnjbvr bnjbvr force-pushed the storetransaction-optional-account branch from 3c6fdb9 to 4df2d96 Compare October 16, 2023 17:00
@bnjbvr bnjbvr force-pushed the storetransaction-optional-account branch from 4df2d96 to 7eb71f9 Compare October 16, 2023 17:01
@codecov
Copy link

codecov bot commented Oct 16, 2023

Codecov Report

Attention: 14 lines in your changes are missing coverage. Please review.

Comparison is base (7f3fef5) 78.71% compared to head (652ebed) 78.68%.
Report is 80 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2710      +/-   ##
==========================================
- Coverage   78.71%   78.68%   -0.03%     
==========================================
  Files         200      200              
  Lines       20359    20392      +33     
==========================================
+ Hits        16025    16046      +21     
- Misses       4334     4346      +12     
Files Coverage Δ
crates/matrix-sdk-crypto/src/dehydrated_devices.rs 100.00% <100.00%> (ø)
crates/matrix-sdk-crypto/src/identities/device.rs 74.90% <100.00%> (ø)
crates/matrix-sdk-crypto/src/identities/manager.rs 83.55% <100.00%> (+0.39%) ⬆️
crates/matrix-sdk-crypto/src/identities/user.rs 87.13% <ø> (ø)
crates/matrix-sdk-crypto/src/olm/signing/mod.rs 88.66% <ø> (-0.06%) ⬇️
...x-sdk-crypto/src/session_manager/group_sessions.rs 95.60% <ø> (ø)
.../matrix-sdk-crypto/src/session_manager/sessions.rs 88.60% <100.00%> (+0.07%) ⬆️
crates/matrix-sdk-crypto/src/store/caches.rs 88.77% <ø> (ø)
...s/matrix-sdk-crypto/src/store/integration_tests.rs 100.00% <100.00%> (ø)
crates/matrix-sdk-crypto/src/store/memorystore.rs 80.86% <100.00%> (+0.36%) ⬆️
... and 10 more

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jplatte jplatte requested review from jplatte and removed request for a team October 19, 2023 12:23
Copy link
Collaborator

@jplatte jplatte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of the first five commits

Copy link
Contributor

@poljar poljar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Suggested some small changes in a review party:

  1. Using a result in tests usually produces worse error reports if a test fails
  2. Let's not use clone_internal() in non-test code
  3. Something for the future, try out if the OwnedRwLockGuard is necessary, maybe we can use the non-owned variant.

Thanks for methodically going through the mess and making sense of it, very nice work.

Copy link
Contributor

@poljar poljar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still looks fine.

@bnjbvr bnjbvr enabled auto-merge (rebase) October 20, 2023 14:48
@bnjbvr bnjbvr merged commit 71627a2 into main Oct 20, 2023
@bnjbvr bnjbvr deleted the storetransaction-optional-account branch October 20, 2023 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants